#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int ge = n % 10;
  int shi = n / 10 % 10;
  int bai = n / 100 % 10;
  int qian = n / 1000;
  ge = 9-ge;
  shi = 9-shi;
  bai = 9-bai;
  qian = 9-qian;
  cout << ge << shi << bai << qian << endl;

  return 0;
}